package com.hivekion.system.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gitee.sunchenbin.mybatis.actable.annotation.ColumnComment;
import com.gitee.sunchenbin.mybatis.actable.annotation.ColumnType;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.hivekion.common.entity.BaseEntity;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 用户表 sys_user
 *
 * @author sutao
 */
@Table("sys_user")
@Data
public class SysUser extends BaseEntity {
    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 50)
    @ColumnComment("登录名")
    private String userName;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 50)
    @ColumnComment("部门ID")
    private String deptId;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 50)
    @ColumnComment("用户昵称")
    private String nickName;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 50)
    @ColumnComment("用户邮箱")
    private String email;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 20)
    @ColumnComment("手机号码")
    private String phoneNumber;

    @TableField
    @ColumnType(value = MySqlTypeConstant.INT, length = 4)
    @ColumnComment("用户性别:0=男,1=女")
    private Integer sex;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 250)
    @ColumnComment("用户头像")
    private String avatar;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 50)
    @ColumnComment("密码")
    private String password;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 50)
    @ColumnComment("盐加密")
    private String salt;

    @TableField
    @ColumnType(value = MySqlTypeConstant.INT, length = 4)
    @ColumnComment("帐号状态:0=正常,1=停用")
    private Integer status;

    @TableField
    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 20)
    @ColumnComment("最后登录IP")
    private String loginIp;

//    @TableField
//    @ColumnType(value = MySqlTypeConstant.VARCHAR, length = 50)
//    @ColumnComment("最后登录时间")
//    private String loginDate;

    @TableField
    @ColumnType(value = MySqlTypeConstant.INT, length = 4)
    @ColumnComment("用户登录失败次数")
    private Integer fails;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.UPDATE)
    @ColumnType(MySqlTypeConstant.TIMESTAMP)
    @ColumnComment("最后登录时间")
    private Date loginDate;

    @TableField
    @ColumnType(value = MySqlTypeConstant.DATETIME)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ColumnComment("上次修改密码时间")
    private Date lastUpdate;

}
